- name: d8.metallb
  rules:
  - alert: D8MetalLBConfigNotLoaded
    expr: metallb_k8s_client_config_loaded_bool == 0
    for: 5m
    labels:
      severity_level: "4"
      tier: cluster
    annotations:
      plk_markup_format: "markdown"
      plk_protocol_version: "1"
      plk_create_group_if_not_exists__d8_metallb_failed: D8MetalLBConfigNotLoaded,tier=~tier,prometheus=deckhouse,kubernetes=~kubernetes
      plk_grouped_by__d8_metallb_failed: D8MetalLBConfigNotLoaded,tier=~tier,prometheus=deckhouse,kubernetes=~kubernetes
      description: |
        {{ $labels.job }} — MetalLB {{ $labels.container }} on {{ $labels.pod}} has not loaded.
        To figure out the problem, check controller logs:
        ```
        kubectl -n d8-metallb logs deploy/controller -c controller
        ```
      summary: MetalLB config not loaded.

  - alert: D8MetalLBConfigStale
    expr: metallb_k8s_client_config_stale_bool == 1
    for: 5m
    labels:
      severity_level: "4"
      tier: cluster
    annotations:
      plk_markup_format: "markdown"
      plk_protocol_version: "1"
      plk_create_group_if_not_exists__d8_metallb_failed: D8MetalLBConfigStale,tier=~tier,prometheus=deckhouse,kubernetes=~kubernetes
      plk_grouped_by__d8_metallb_failed: D8MetalLBConfigStale,tier=~tier,prometheus=deckhouse,kubernetes=~kubernetes
      description: |
        {{ $labels.job }} — MetalLB {{ $labels.container }} on {{ $labels.pod}} has run on a stale configuration, because the latest config failed to load.
        To figure out the problem, check controller logs:
        ```
        kubectl -n d8-metallb logs deploy/controller -c controller
        ```
      summary: MetalLB running on a stale configuration, because the latest config failed to load.

  - alert: D8MetalLBBGPSessionDown
    expr: metallb_bgp_session_up == 0
    for: 5m
    labels:
      severity_level: "4"
      tier: cluster
    annotations:
      plk_markup_format: "markdown"
      plk_protocol_version: "1"
      plk_create_group_if_not_exists__d8_metallb_failed: D8MetalLBBGPSessionDown,tier=~tier,prometheus=deckhouse,kubernetes=~kubernetes
      plk_grouped_by__d8_metallb_failed: D8MetalLBBGPSessionDown,tier=~tier,prometheus=deckhouse,kubernetes=~kubernetes
      description: |
        {{ $labels.job }} — MetalLB {{ $labels.container }} on {{ $labels.pod}} has BGP session {{ $labels.peer }} down.
        Details are in logs:
        ```
        kubectl -n d8-metallb logs daemonset/speaker -c speaker
        ```
      summary: MetalLB BGP session down.
